<template>
	<ResourcePage ref="refPageController" page-name="系统性能日志" scene="performance" @get:list="getTableData">
		<template #columns>
			<el-table-column prop="cpu" label="CPU使用率" align="center">
				<template #default="{ row }">
					{{ row.cpu }}%
				</template>
			</el-table-column>
			<el-table-column prop="memory" label="内存使用率" align="center">
				<template #default="{ row }">
					{{ row.memory_usage }}%
				</template>
			</el-table-column>
			<el-table-column prop="total_memory" label="最大内存" align="center" />
			<el-table-column prop="available_memory" label="可用内存" align="center" />
			<el-table-column prop="add_time" label="读取时间" align="center" />
		</template>
	</ResourcePage>
</template>

<script setup>
import { ref } from 'vue'
import http from '@/utils/http'

import ResourcePage from '../components/ResourcePage.vue'

const refPageController = ref(null)

const getTableData = (postData, { resolve }) => {
	http.get('/v1/logs/performance', { params: postData }).then(res => {
		if (res.code == 1) {
			resolve({
				list: res.data.data,
				total: res.data.total
			})
		}
	})
}
</script>
